﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DeJC.DAL.Model;

namespace DeJC.BLL.Managers {
    public static class UserContactManager {
        public static IEnumerable<UserContact> GetUserContacts() {
            IEnumerable<UserContact> userContacts;
            using(UnitOfWork unitOfWork=new UnitOfWork()) {
                userContacts=unitOfWork.UserContactRepository.GetAll();
            }
            return userContacts;
        }

        public static bool AddUserContact(UserContact userContact) {
            using(UnitOfWork unitOfWork=new UnitOfWork()) {
                unitOfWork.UserContactRepository.Add(userContact);
                unitOfWork.Save();
            }
            return true;
        }

        // public bool UpdateUserContact(UserContact userContact, int id)
        // {
        // using (UnitOfWork unitOfWork = new UnitOfWork())
        // {
        // var userContactEntity = unitOfWork.UserContactRepository.GetById(id);
        // userContactEntity.Title = userContact.Title;
        // userContactEntity.FirstName = userContact.FirstName;
        // userContactEntity.LastName = userContact.LastName;
        // userContactEntity.ModifiedDate = DateTime.Now;
        // unitOfWork.Save();
        // }
        // return true;
        // }

        public static bool DeleteUserContact(int id) {
            using(UnitOfWork unitOfWork=new UnitOfWork()) {
                UserContact userContact=unitOfWork.UserContactRepository.GetById(id);
                userContact.Deleted=true;
                userContact.DeletedDate=DateTime.Now;
                unitOfWork.Save();
            }
            return true;
        }

        // public List<UserContact> GetUserContactPaged(int page, int rows, out int totalCount)
        // {
        // List<UserContact> userContacts;
        // using (UnitOfWork unitOfWork = new UnitOfWork())
        // {
        // userContacts = unitOfWork.UserContactRepository.GetUserContactPaged
        // (page, rows, out totalCount);
        // }
        // return userContacts;
        // }
        public static UserContact GetById(int id) {
            UserContact userContact;
            using(UnitOfWork unitOfWork=new UnitOfWork()) {
                userContact=unitOfWork.UserContactRepository.GetById(id);
            }
            return userContact;
        }
    }
}
